<template>
      <el-dialog
        v-model="centerDialogVisible"
        title="人员信息"
        width="60%"
        align-center
     >
        <el-table :data="tableData" stripe style="width: 100%" height="300">
            <el-table-column prop="lastname" label="姓名" />
            <el-table-column prop="workcode" label="编号"  />
            <el-table-column prop="sex" label="性别"  />
            <el-table-column prop="manager" label="直接上级" />
            <el-table-column prop="loginid" label="登录名" />
        </el-table>
        <template #footer>
        <span class="dialog-footer">
            <el-button type="primary" @click="centerDialogVisible = false">
            关闭
            </el-button>
        </span>
        </template>
    </el-dialog>
  </template>
  
  <script>
    import { ElDialog,ElButton,ElTable,ElMessage } from 'element-plus'
    import {selectPerson,selectVirtualPerson} from '@/api/chart'
  
  export default {
    name: 'ViewDialog',
    components: {
      ElDialog,
      ElButton,
      ElTable
    },
    data() {
      return {
        centerDialogVisible:false,
        tableData:[],
        params:{
            pid:'',
            id:''
        },
        virtual:1
      };
    },
    created() {
       
    },
    methods: {
        openDialog(data,virtual){
            this.params.id = data.id;
            this.virtual = virtual;
            this.tableList(); 
        },
        tableList() {
          this.virtual == 1 ? selectPerson(this.params).then(res=>{
                this.tableData = res.data.data;
                this.centerDialogVisible = true;
                })
            .catch(err=>{
                ElMessage.error(err.msg);
            }) : selectVirtualPerson(this.params).then(res=>{
                this.tableData = res.data.data;
                this.centerDialogVisible = true;
                })
            .catch(err=>{
                ElMessage.error(err.msg);
            })
        },

    }
  }
  </script>
  
  <style scoped>
    .dialog-footer button:first-child {
    margin-right: 10px;
    }
</style>
  